/**
 * N堆石子，red每次拿一堆，purple每次各拿一个
 * 问red最多能拿多少
 * 显然贪心，red每次拿最多的一堆即可
 */
#include <bits/stdc++.h>
using namespace std;

using llt = long long;
using vll = vector<llt>;

vll A;
int N;

template<typename T>
istream & operator >> (istream & is, vector<T> & v){
    for(auto & i : v) is >> i;
    return is;
}

void work(){
    cin >> N;
    A.assign(N, {});
    cin >> A;

    sort(A.begin(), A.end());
    llt ans = 0;
    for(int level=0;;++level){
        if(A.back() <= level) break;
        ans += A.back() - level;
        A.pop_back();
        if(A.empty()) break;
    }
    cout << ans << endl;
    return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);	
    int nofkase = 1;
    // cin >> nofkase;
    while(nofkase--) work();
	return 0;
}